BASE:=$(shell pwd | xargs basename)
DIRECTORIES=$(filter-out %makefile, ${wildcard src/*})
OUTER_DIRECTORIES=$(filter-out %makefile %README, ${wildcard ./*})
VERSION=?-g

EXTENSION=
ifeq ($(VERSION),-g)
EXTENSION=-g
endif

ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
-include $(SOURCE_DEPENDENCIES)
endif

all:
	@echo $(DIRECTORIES)
	@for i in $(DIRECTORIES); do \
		cd $$i; $(MAKE) VERSION=$(VERSION) ; cd ../..; \
	done
	cd bin; $(MAKE) VERSION=$(VERSION) ; cd ..;

documentation: 
	cd doc; $(MAKE); cd ..;

clean:	
	@echo $(OUTER_DIRECTORIES)
	@for j in $(OUTER_DIRECTORIES); do \
		cd $$j; $(MAKE) clean; cd ..; \
	done

echo:
	@echo $(VERSION)
	@echo $(EXTENSION)	
	@echo $(OUTER_DIRECTORIES)
	@echo $(DIRECTORIES)


#	rm -rf *.o lib*.a lib*.so m
